﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using System.ComponentModel;
using FinPlusCommon;
using u = FinPlusUtility.Utility;
using log = Logger.Logger;

namespace FinPlusWPFControls
{
    public partial class FinPlusWait : Popup, IFinPlusComponent
    {
        public string Id { get; set; }
        public string[] States { get { return new string[] { }; } }
        public string[] TestStates { get { return new string[] { }; } }
        public IFinPlusFunctions Model { get { return null; } }
        public bool IsValid { get; set; }
        public string ModelTest { get { return null; } }

        //construct
        public FinPlusWait(UIElement placementTarget, string text)
        {
            //TODO REMOVE TRY CATC FROM CONSTRUCTOR TEMP FIX PROB IN XBAP WINDOW
            try
            {
                PlacementTarget = this;

                InitializeComponent();
          
                display.Text = text;

                PlacementTarget = placementTarget;
                var window = ControlSearch.FindVisualParent<FinPlusWindow>(placementTarget);
                window.LocationChanged += Window_Move;
                window.SizeChanged += Window_Move;
            }
            catch
            {
                //TODO REMOVE TRY CATC FROM CONSTRUCTOR TEMP FIX PROB IN XBAP WINDOW
            }
        }

        //common control interface
        public void Dock(object control, string dock){ }

        public void Initialise()
        { 
        
        }

        public void CommandRouter(IFinPlusFunction func) { }

        public void Dispose()
        {
            IsOpen = false;
        }

        //events
        private void Window_Move(object sender, EventArgs a)
        {
            var offset = HorizontalOffset;
            HorizontalOffset = offset + 1;
            HorizontalOffset = offset;
        }
    }
}
